{{csrf_field()}}
<div style="padding:30px 30px 30px 10px" >
    <div class="layui-form-item">
        <label class="layui-form-label">属性名称：</label>
        <div class="layui-input-block">
            <input type="text" name="name" id="name"  value="{{$info->name?? ''}}" lay-verify="required"  lay-reqText="属性名称必填" placeholder="请输入参数名称" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序：</label>
        <div class="layui-input-block">
            <input type="number" name="sort" value="{{$info->sort?? ''}}" id="sort" lay-verify="required" placeholder="越小越大" autocomplete="off" class="layui-input">
        </div>
    </div>
    @if(isset($info->hasManyValue) && !$info->hasManyValue->isEmpty())
        @foreach($info->hasManyValue as $key =>$val)
        <div class="layui-form-item">
            <label class="layui-form-label">属性值：</label>
            <div class="layui-input-block">
                <input type="text" lay-verify="required" value="{{$val->value}}" lay-reqText="属性值必填"  name="value[]" id="value" placeholder="请输入属性值" autocomplete="off" class="layui-input" style="width: 85%;display: inline-block;">

                <div class="layui-btn-group">
                    @if($key >1)
                        <a class="layui-btn  del-value" ><i class="layui-icon "></i></a>
                    @else
                        <a class="layui-btn  add-value" ><i class="layui-icon "></i></a>
                    @endif
                </div>
            </div>

        </div>
        @endforeach
    @else
        <div class="layui-form-item">
            <label class="layui-form-label">属性值：</label>
            <div class="layui-input-block">
                <input type="text" lay-verify="required"  lay-reqText="属性值必填"  name="value[]" id="value" placeholder="请输入属性值" autocomplete="off" class="layui-input" style="width: 85%;display: inline-block;">

                <div class="layui-btn-group">
                    <a class="layui-btn  add-value" ><i class="layui-icon "></i></a>
                </div>
            </div>

        </div>
    @endif
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-fluid"  lay-submit lay-filter="popup-save" >保 存</button>
        </div>
    </div>

  </div>
<script>
    //渲染表单
    layui.use(['jquery','form'], function(){
        var $ = layui.jquery,
            form = layui.form;
        var html='';
    $(document).on('click', '.add-value',function(){
        html=
            '<div class="layui-form-item">'+
            '<label class="layui-form-label">属性值：</label>'+
            '<div class="layui-input-block">'+
            '<input type="text" name="value[]" lay-verify="required" lay-reqText="属性值必填" placeholder="请输入属性值" autocomplete="off" class="layui-input" style="width: 80%;display: inline-block;">'+
            '<div class="layui-btn-group">'+
            '<button class="layui-btn  del-value" style="height: 36px;margin-left:4px !important;"><i class="layui-icon"></i></button>'+
            '</div>'+
            '</div>'+
            '</div>';
        $(".layui-form-item").last().before(html);
        return false;
    });

    $(document).on('click','.del-value',function(){
        $(this).parent().parent().parent().remove();
        return false;
    });

    });
</script>